﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using E_Shop.Common;
using ESHOP.UTIL;
using ESHOP.Domain;
using ESHOP.DAO;
namespace E_Shop
{
    public partial class SiteProductDetail : Authentication
    {

        protected void Page_Load(object sender, EventArgs e)
        {
           
            
            BindataToDetails();
            
        }

        private void BindataToDetails()
        {
            String ma = Request.QueryString["id"];
            String type = Request.QueryString["type"];
            if (type.Equals("1"))
            {
                
                SELL _sell = new SellLeadDao().Get(ma);
                if (_sell != null)
                {
                    Image1.ImageUrl = "../Images/Product/" + _sell.HINHANH;
                    CONGTY _congty = new CONGTYDAO().Get(_sell.MACONGTY);
                    Session[Constants.SESSION_COMAPNY] = _congty;
                    lblCompanyName.Text = String.IsNullOrEmpty(_congty.TENCONGTY) ? "" : _congty.TENCONGTY.ToString();
                    lblRegion.Text = _sell.QUOCGIA.TENQUOCGIA == null ? "" : _sell.QUOCGIA.TENQUOCGIA.ToString();
                    lblcontact.Text = _congty.CONTACT == null ? "" : _congty.CONTACT.ToString();
                    lblPhone.Text = _congty.PHONE == null ? "" : _congty.PHONE.ToString();
                    lblEmail.Text = _congty.Email == null ? "" : _congty.Email.ToString();
                    lnlAddress.Text = _congty.ADDRESS == null ? "" : _congty.ADDRESS.ToString();
                    lbProductDec.Text = _sell.DESCRIPTION == null ? "" : _sell.DESCRIPTION.ToString();
                    Upinfor.Update();
                }
            }
            else if (type.Equals("2"))
            {

                BUY _buy = new BuyLeadDAO().Get(ma);
                if (_buy != null)
                {
                    Image1.ImageUrl = "../Images/Product/" + _buy.HINHANH;
                    CONGTY _congty = new CONGTYDAO().Get(_buy.MACONGTY);
                    Session[Constants.SESSION_COMAPNY] = _congty;
                    lblCompanyName.Text = String.IsNullOrEmpty(_congty.TENCONGTY) ? "" : _congty.TENCONGTY.ToString();
                    lblRegion.Text = _buy.QUOCGIA.TENQUOCGIA == null ? "" : _buy.QUOCGIA.TENQUOCGIA.ToString();
                    lblcontact.Text = _congty.CONTACT == null ? "" : _congty.CONTACT.ToString();
                    lblPhone.Text = _congty.PHONE == null ? "" : _congty.PHONE.ToString();
                    lblEmail.Text = _congty.Email == null ? "" : _congty.Email.ToString();
                    lnlAddress.Text = _congty.ADDRESS == null ? "" : _congty.ADDRESS.ToString();
                    lbProductDec.Text = _buy.MOTA == null ? "" : _buy.MOTA.ToString();
                    Upinfor.Update();
                }
            }
           
         
           
        }
        protected void LinkBtnaddtocard_Click(object sender, EventArgs e)
        {


        }

    }
}